<template>
  <el-dialog title="选择车辆" :visible.sync="dialogBoole" width="590px">
    <el-form :model="form" :rules="rules" ref="form" label-width="85px">
      <el-form-item label="过户时间:" prop="transferTime">
        <el-date-picker v-model="form.transferTime" type="date" value-format='yyyy-MM-dd' style="width: 100%"
                        placeholder="选择日期"/>
      </el-form-item>
      <el-form-item label="附件:" prop="transferAttachmentOss">
        <image-common v-model="form.transferAttachmentOss" :limit="5" :disabled="false" :upType="2"/>
      </el-form-item>
      <el-form-item label="说明:" prop="transferRemark">
        <el-input type="textarea" v-model="form.transferRemark" placeholder="请输入说明"
                  :rows="6" maxlength="500" show-word-limit/>
      </el-form-item>

    </el-form>

    <div slot="footer" class="dialog-footer">
      <el-button @click="handleDialog(1)">取 消</el-button>
      <el-button type="primary" @click="handleDialog(2)">确 定</el-button>
    </div>

  </el-dialog>
</template>

<script>
import {carTransfer} from '@/api/vehicleDisposal/routineApplyFor.js'

export default {
  name: 'TransferOwnership',//车辆过户
  computed: {},
  watch: {},
  data() {
    return {
      form: {
        vehicleDisposalId: '',
        transferTime: '',
        transferAttachmentOss: '',
        transferRemark: ''
      },
      dialogBoole: false,
      rules: {
        transferTime: [{required: true, message: '请选择过户时间', trigger: 'blur'}]
      }
    };
  },
  created() {
  },
  mounted() {

  },
  methods: {
    handleDialog(type) {
      if (type === 1) {
        this.transferTime = ''
        this.transferAttachmentOss= ''
        this.transferRemark=''
        this.dialogBoole = false
      }
      if (type === 2) {
        this.$refs.form.validate((valid) => {
          if (valid) {
            carTransfer(this.form).then(res => {
              if (res.code === 200) {
                this.dialogBoole = false
                this.$message.success('车辆过户成功')
                this.$emit('refresh')
              }
            })
          }
        });
      }

    },

    handleOpen(id) {
      this.form.vehicleDisposalId = id
      this.dialogBoole = true
    }
  },
};
</script>

<style scoped lang=""></style>


